// packageC/Myshaky/Registration/Registration.js
// import util from '../../../utils/util.js';
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    lisNum:10,

    // more
    isLoadMore: true,
    page: 1,
    last_page: 0
  },
  onLoad: function (options) {
    this.setData({
      activity_id: options.id
    });
    this.getrenshu();
  },

  onReachBottom: function () {
    if (!this.data.isLoadMore) return;
    this._getMoreData();
  },

  getrenshu() {
    let urlStr = app.getNetAddresss("plugin.activity-apply.api.activity.getDetails");
    let that = this;
    app._getNetWork({
      url: urlStr,
      data: {
        activity_id: that.data.activity_id,
        page: 1
      },
      success: function (resdata) {
        var res = resdata.data;
        if (res.result == 1) {
          if(res.data.data.length == 0){
            that.setData({
              datalist: res.data.data,
              isLoadMore: false,
              kong:true
            });
          }else{
            that.setData({
              datalist: res.data.data,
              last_page: res.data.last_page,
              kong: false
            });
          }
          
        }
      },
      fail: function (res) {
      }
    });
  },

  _getMoreData () {
    let urlStr = app.getNetAddresss("plugin.activity-apply.api.activity.getDetails");
    if (this.data.page >= this.data.last_page) {
      this.setData({
        isLoadMore: false
      });
      return;
    }
    this.setData({
      page: this.data.page + 1
    });
    app._getNetWork({
      url: urlStr,
      data: {
        activity_id: this.data.activity_id,
        page: this.data.page
      },
      success: (resdata) => {
        if (resdata.data.result == 1) {
          let res = resdata.data.data;
          this.setData({
            isLoadMore: true,
            datalist: this.data.datalist.concat(res.data)
          });
        } else {
          this.setData({
            page: this.data.page - 1,
            isLoadMore: false
          });
          return;
        }
      },
      fail: function(resdata) {
      }
    });
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

});